class Solution(object):
    def removeOuterParentheses(self, s):
        """
        :type s: str
        :rtype: str
        """
        n = len(s)
        left_index = 0
        right_index = 0
        count = 0
        t = ''
        while right_index < n:
            if s[right_index] == '(':
                count += 1
            else:
                count -= 1
            if not count:
                t += s[left_index + 1: right_index]
                left_index = right_index + 1
            right_index += 1
        return t


data = Solution()
s = "(()())(())"
print(data.removeOuterParentheses(s))
